//
//  HJStatus.swift
//  Weibo
//
//  Created by 韩佳 on 16/4/20.
//  Copyright © 2016年 ddg. All rights reserved.
//

import UIKit

class HJStatus: NSObject {
    /// 当前微博的内容
    var text: String?
    /// 微博的创建时间
    var created_at: String?
    /// 来源
    var source: String?
    /// 当前微博的用户信息
    var user: HJUser?
    /// 当前微博转发微博，因为其内部字段与 HMStatus 一样，所以就设置其类型为 HMStatu
    var retweeted_status:HJStatus?
    /// 配图数组
    var pic_urls: [HJStatusPhontoInfo]?
    
    var id:Int64 = 0
    
    init(dict: [String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user"{
            guard let dict = value as? [String: AnyObject] else{
                return
            }
            user = HJUser(dict: dict)
            
        }else if key == "retweeted_status"{
            guard let dict = value as? [String: AnyObject] else{
                return
            }
            retweeted_status = HJStatus(dict: dict)
            
        }else if key == "pic_urls"{
            guard let dicts = value as? [[String:AnyObject]] else{
                return
            }
            var tempArr = [HJStatusPhontoInfo]()
            for dict in dicts {
                let info = HJStatusPhontoInfo(dict: dict)
                tempArr.append(info)
            }
            pic_urls = tempArr
        }else{
           super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
